/*
 * init/main.c
 *
 * last modified by ChenJie at 2007.07.15
 *
 */
#include <clinux/kernel.h>
#include <clinux/mm.h>
#include <clinux/sched.h>
#include <clinux/time.h>
#include <asm/i8259.h>
#include <asm/i386.h>

#define __LIBRARY__
#include <unistd.h>

static inline _syscall0(int,fork)

_syscall1(int,user_print,const char*, fmt)

int printf(const char *fmt, ...);

extern int main(void);

extern void cpu_info(void);

int main(void)
{
	int i;
	printk("Kernel Size = %dKB\n\r", KERNEL_SIZE>>10);
	cpu_info();
	i8259_init();
	mm_init(EXT_MM_SIZE);
	exception_init();
	time_init();
	sched_init();
	
	printk("MEM_SIZE = %dMb.............................\n\r", mm_size>>20);
	sti();
	move_to_user_mode();
	i = fork();
	if(i==0){
		printf("task1 is running\n\r");
		fork();
	}else{
		printf("task0 is running, fork=%d\n\r", i);
		fork();
	}

	//__asm__ __volatile__("movl $0, %%eax\n\t"
	//		"int $0x80\n\t"
	//		::);

/*	while(1){
		if(i==0){
			
			printk("0");
		}
		i++;
	}
*/
	while(1);

}
double v = 0;
void task1(void)
{
	unsigned short i=0;
	double f;
	sti();
	while(1);
	move_to_user_mode();
	printk("task1 is running\n\r");
	f = 1.1;
	while(1){
		if(i==0){
			f = f * 2.12;
			printk("1");
		}
		i++;
		v = f;
	}
	while(1);

}
